﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using VersionComparer.Base;
using VersionComparer.DataModel.Assemblies.Images;

namespace VersionComparer.DataModel.Assemblies
{
    [Serializable]
    [Order(4)]
    public class DelegateItem : MethodItem
    {

        
        public override void InitializeAssemblyItem(MethodInfo value)
        {
            base.InitializeAssemblyItem(value);
            IsVirtual = false;
            Text = string.Format("{0}delegate {3} {1} ({2})", AccessorsAsCode, Name , GetParametersCode (value , false), ReturnType(value , false));
        }

        protected override string GetName(MethodInfo value)
        {
            return ShallowName;
        }

        public override bool IsVirtual
        {
            get
            {
                return false;
            }
            protected set
            {
                base.IsVirtual = value;
            }
        }
        protected override string GetFullText(MethodInfo value)
        {
            IsVirtual = false;
            return string.Format("{0}delegate {3} {1} ({2});", AccessorsAsCode, Name, GetParametersCode(value, true), ReturnType(value, true));
        }

        protected override void BuildRtf(Base.RtfBuilder builder, bool differencesOnly, bool useParentColor)
        {
            BuildAttributesRtf(builder, differencesOnly, useParentColor);
            builder.Append(AccessorsAsCode, keywordColor);
            builder.Append("delegate ", keywordColor);
            builder.Append(UnderlyingTypeRtf);
            if (UnderlyingTypeRtf.Text.Length > 0)
                builder.Append(" ");
            builder.Append(string.Format("{0}( ", Name));
            BuildParametersRtf(builder, differencesOnly, useParentColor);
            builder.AppendLine(");");
            
        }

        protected override System.Drawing.Image GetSpecificImage()
        {
            return AssemblyResources._delegate;
        }

    }
}
